package com.sprider.jsoup.service;

import java.io.IOException;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public abstract class SpriderAbstractService {
	public Document doc;
	public String url;

	/**
	 * 返回document根据uri
	 * 
	 * @param uri
	 * @return
	 * @throws IOException
	 */
	public Document createDocument(String url) throws IOException {
		this.url=url;
		Connection c = Jsoup.connect(url);
		Document doc = c.get();
		return doc;
	}

	/**
	 * 解析document
	 * @throws IOException 
	 */
	protected abstract Object parse() throws IOException;

	public Object parseUrl(String url) throws IOException {
		doc = this.createDocument(url);
		return this.parse();
	}

}
